<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row type="flex">
          <a-col>
            <a-button icon="plus" style="margin-right: 20px" type="primary" @click="openAdd()">新增</a-button>
            <a-divider style="margin-right: 20px" type="vertical"/>
          </a-col>
          <a-col :md="5" :sm="7" style="margin-left: 15px">
            <a-form-item label="标题">
              <j-input v-model="queryParam.title" placeholder="请输入标题"></j-input>
            </a-form-item>
          </a-col>
          <a-col :md="4" :sm="5" style="margin-left: 15px">
            <a-form-item label="范围">
              <a-select v-model="queryParam.origin" placeholder="请选择范围">
                <a-select-option v-for="(i,index) in selectList" :key="index" :value="i.key">{{ i.name }}
                </a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :md="4" :sm="5" style="margin-left: 15px">
            <a-form-item label="类别">
              <a-select v-model="queryParam.channelId" placeholder="请选择文章类型">
                <a-select-option v-for="(i,index) in channelIdList" :key="index" :value="i.key">{{ i.name }}
                </a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col flex="auto" style="margin-left: 15px">
            <span class="table-page-search-submitButtons" style="float: left; overflow: hidden;margin-right: 20px">
              <a-button icon="search" style="margin-left: 10px" type="primary" @click="searchQuery">查询</a-button>
              <a-popover :overlayStyle="{background: 'white'}" placement="topLeft">
                <template slot="content">
                  <a-icon theme="twoTone" two-tone-color="#52c41a" type="exclamation-circle"/><span
                  style="margin-left: 5px">可以点击重置来重新筛选结果</span>
                </template>
                <a-button
                  icon="reload"
                  style="margin-left: 8px"
                  @click="searchReset"
                >重置</a-button>
              </a-popover>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <div>
      <a-table
        ref="table"
        :columns="columns"
        :dataSource="dataSource"
        :loading="loading"
        :pagination="ipagination"
        bordered
        rowKey="id"
        size="middle"
        @change="handleTableChange">
        <span slot="originUrl" slot-scope="text, record">
           <a slot="originUrl" :href="record.originUrl" style="color: #595959!important;" target="_blank">{{ text }}</a>
        </span>
        <span slot="action" slot-scope="text, record">
          <a-button style="margin-right: 10px" type="primary" @click="handleEdit(record)">
            编辑
          </a-button>
            <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
              <a-button>
                删除
              </a-button>
            </a-popconfirm>
        </span>
      </a-table>
      <!--      <eng-consumption-modal ref="modalForm" @ok="modalFormOk"></eng-consumption-modal>-->
      <knowledge-modal ref="modalForm" @ok="modalFormOk"></knowledge-modal>

    </div>
  </a-card>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JInput from '@comp/jeecg/JInput'
import KnowledgeModal from '@views/dataVisualization/components/knowledgeModal'

export default {
  name: 'knowledgeTable',
  mixins: [JeecgListMixin],
  components: {
    KnowledgeModal,
    JInput
  },
  data() {
    return {
      selectList: [
        { name: '上海市', key: '上海市' },
        { name: '外省市', key: '外省市' },
        { name: '国际', key: '国际' },
        { name: '企业', key: '企业' },
      ],
      channelIdList: [
        { name: '标准', key: '标准' },
        { name: '建筑类', key: '建筑类' },
        { name: '交通类', key: '交通类' },
        { name: '平台类', key: '平台类' },
        { name: '绿色金融', key: '绿色金融' },
      ],
      queryParam: {
        origin: '上海市'
      },
      confirmLoading: false,
      title: '',
      visible: false,
      dataSource: [],
      form: this.$form.createForm(this),
      dialogStyle: {
        top: '200px'
      },
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      columns: [
        {
          title: '类型',
          align: 'center',
          dataIndex: 'channelId',
          width:100
        },
        {
          title: '标题',
          align: 'left',
          url: 'originUrl',
          dataIndex: 'title',
          scopedSlots: { customRender: 'originUrl' }
        },
        {
          title: '范围',
          align: 'center',
          dataIndex: 'origin',
          width:100
        },
        {
          title: '创建时间',
          align: 'center',
          dataIndex: 'createTime',
          width:100
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: '/cxm/cmsArticle/list',
        delete: '/cxm/cmsArticle/delete',
      }
    }
  },
  methods: {
    openAdd() {
      this.$refs.modalForm.add()
      this.$refs.modalForm.title = '新增'
      this.$refs.modalForm.disableSubmit = false
    }
  }
}
</script>

<style scoped>

</style>